home *** CD-ROM | disk | FTP | other *** search
- /* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Forecastfox.
- *
- * The Initial Developer of the Original Code is
- * Jon Stritar <jstritar@MIT.EDU>.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Jon Stritar <jstritar@MIT.EDU>
- * Richard Klein <richwklein@mchsi.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
- /* XPCOM Constants */
- const CLASS_ID = Components.ID("{3BEB2141-06DC-448c-BB1F-6EBE08A3764C}");
- const CLASS_NAME = "Forecastfox Namespace Resolver Component";
- const CONTRACT_ID = "@ensolis.com/forecastfox/resolver;1";
-
- /******************************************************************************
- * ffResolver Component
- ******************************************************************************/
- function ffResolver()
- {
- //add our prefixes
- this._prefixes = new Object();
- this._prefixes["adc"] = "http://www.accuweather.com";
- };
-
- ffResolver.prototype = {
- _prefixes: null,
-
- lookupNamespaceURI: function(aPrefix)
- {
- if (aPrefix in this._prefixes)
- return this._prefixes[aPrefix];
- else
- return null;
- },
-
- ///////////////////////////
- // nsIClassInfo
- getInterfaces: function(aCount)
- {
- var ifaces = new Array();
- ifaces.push(Components.interfaces.nsIDOMXPathNSResolver);
- ifaces.push(Components.interfaces.nsIClassInfo);
- ifaces.push(Components.interfaces.nsISupports);
- aCount.value = ifaces.length;
- return ifaces;
- },
-
- getHelperForLanguage: function(aLanguage) { return null; },
- get contractID() { return CONTRACT_ID; },
- get classID() { return CLASS_ID; },
- get classDescription() { return CLASS_NAME; },
- get implementationLanguage() { return Components.interfaces.nsIProgrammingLanguage.JAVASCRIPT; },
- get flags() { return Components.interfaces.nsIClassInfo.THREADSAFE; },
-
- ///////////////////////////
- // nsISupports
- QueryInterface: function (aIID)
- {
- if (!aIID.equals(Components.interfaces.nsIDOMXPathNSResolver) &&
- !aIID.equals(Components.interfaces.nsIClassInfo) &&
- !aIID.equals(Components.interfaces.nsISupports))
- throw Components.results.NS_ERROR_NO_INTERFACE;
- return this;
- }
- };
-
- /******************************************************************************
- * XPCOM Functions for construction and registration
- ******************************************************************************/
- var gModule = {
- _firstTime: true,
- registerSelf: function(aCompMgr, aFileSpec, aLocation, aType)
- {
- if (this._firstTime) {
- this._firstTime = false;
- throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
- };
- aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
- aCompMgr.registerFactoryLocation(CLASS_ID, CLASS_NAME, CONTRACT_ID, aFileSpec, aLocation, aType);
- },
-
- unregisterSelf: function(aCompMgr, aLocation, aType)
- {
- aCompMgr = aCompMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
- aCompMgr.unregisterFactoryLocation(CLASS_ID, aLocation);
- },
-
- getClassObject: function(aCompMgr, aCID, aIID)
- {
- if (!aIID.equals(Components.interfaces.nsIFactory))
- throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
-
- if (aCID.equals(CLASS_ID))
- return gFactory;
-
- throw Components.results.NS_ERROR_NO_INTERFACE;
- },
-
- canUnload: function(aCompMgr) { return true; }
- };
-
- var gFactory = {
- createInstance: function (aOuter, aIID)
- {
- if (aOuter != null)
- throw Components.results.NS_ERROR_NO_AGGREGATION;
- return (new ffResolver()).QueryInterface(aIID);
- }
- };
-
- function NSGetModule(aCompMgr, aFileSpec) { return gModule; }